#面向过程定义函数
def cut(hairlength):
    hairlength = hairlength - 25
    return  hairlength
#使用函数
print(cut(30))

#面向对象
class  Barber:
    def cut(self,hairlength):
        hairlength = hairlength - 25
        return hairlength
class Customer:
    hairlength=0
customer=Customer()
customer.hairlength=30
barber=Barber()
print(barber.cut(customer.hairlength))

#定义一个种类，分类的依据是什么，是否符合已知种类的特征，
#找到现实世界中对应的类，但是只描述本次编程关心的特征
class Student: #类的定义是一个模板
    sno=''#学生有学号，学号是学生的特征，学生要能保存和提供学号才是学生，能够定义一个变量来存放现实世界中对应的数据，就叫描述了类的特征
    name=''
    sex=''
    high=0
    def __init__(self,sno,name,sex,high):#self 当前被造出来的对象自己
        print("构造方法被调用")
        self.sno = sno #将外部传递过来的学号 赋值给当前对象的学号
        self.name = name  # 将外部传递过来的学号 赋值给当前对象的学号
        self.sex = sex  # 将外部传递过来的学号 赋值给当前对象的学号
        self.high = high  # 将外部传递过来的学号 赋值给当前对象的学号
student1=Student("00001","张三","男",172) # = 左边是变量  右边是具体的值 申请调用类的构造方法产生一个对象
#print(type(student1.sno))
# student1.sno="00001" # student1.name="张三" # student1.sex="男" # student1.high=172
student2=Student("00002","李四","女",168)
student3=Student("00003","王五","男",175)
students = [student1,student2,student3] # 学生对象列表
for student in students: #找出全班同学的身高
    print(student.high)
print('------------')

high1=172
high2=171
high3=173
highs = [high1,high2,high3]  #身高列表
for high in highs:
    print(high)

#游戏角色类
class GameRole:
    name=''
    desc=''
    hp=0
    mp=0
    attackSpeed=0
    def __init__(self,name,desc,hp,mp,attackSpeed):
        self.name = name
        self.desc = desc
        self.hp = hp
        self.mp = mp
        self.attackSpeed = attackSpeed
delawen=GameRole('德莱文','持双斧的人族战士',700,100,50)
delawen=GameRole('卡莎','精灵族',600,90,100)












